import { TouchSpaceEnter } from "../event/touch_space_enter.slint";
import { ButtonBase } from "button_base.slint";

// see button base, button removed @children
export component Button inherits ButtonBase {
    logic_color: root.enabled && (touch.has_hover || touch.has_focus) ? root.hover_color : root.color;

    callback clicked;

    states [
        is-loading when root.loading: {
            touch.space_enter_enabled: false;
        }
        disabled when !root.enabled: {
            touch.space_enter_enabled: false;
        }
    ]

    // support toggled and mouse cursor
    touch:= TouchSpaceEnter {
        mouse-cursor: root.mouse_cursor;

        clicked => {
            if (root.enabled) {
                root.clicked();
            }
        }
    }
}